package comparison.sort;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class NumberOfSortingActivity extends Activity implements OnClickListener {
	private static final int SELECTIONSORT = R.id.algorithm1;
	private static final int QUICKSORT=R.id.algorithm2;
	private static final int SHELLSORT=R.id.algorithm3;
	
	private EditText numberData;
	private Button ok;
	private TextView nameAlgoSort;
	private int algorithm; 
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_number_of_data_sort);
		numberData = (EditText)findViewById(R.id.numberOfData);
		ok = (Button)findViewById(R.id.ok);
		nameAlgoSort = (TextView)findViewById(R.id.tVnameAlgoSort1);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		//Get algorithm chosen
		Intent intent = getIntent();
		Bundle bundle = intent.getExtras();
		algorithm =bundle.getInt("ALGORITHM"); 
		//Show mesg algorithm chosen to screen 
		switch (algorithm) {
		case SELECTIONSORT:
			nameAlgoSort.setText("The Selection Sort is chosen");
			break;
		case QUICKSORT:
			nameAlgoSort.setText("The Quick Sort is chosen");
			break;
		case SHELLSORT:
			nameAlgoSort.setText("The Shell Sort is chosen");
			break;
		default:
			break;
		}
		ok.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.ok:
			//Put Algorithm and number of data sorting
			Intent intentChoose = new Intent("comparison.sort.DATASORTING");
			Bundle bundleChoose = new Bundle();
			bundleChoose.putInt("NUMBERDATA",Integer.parseInt(numberData.getText().toString()));
			bundleChoose.putInt("ALGORITHM", algorithm);
			intentChoose.putExtras(bundleChoose);
			startActivity(intentChoose);
			break;
		default:
			break;
		}
	}

}
